<%--
  Created by IntelliJ IDEA.
  User: ringo
  Date: 2025/11/11
  Time: 18:42
  To change this template use File | Settings | File Templates.
  购物车页面
--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>借阅清单</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/asserts/css/borrowCart.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/asserts/css/bootstrap.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/asserts/js/bootstrap.min.js">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/asserts/css/common.css">
</head>
<body>
<%@include file="/asserts/common/header.jsp" %>
<div class="container">
    <c:choose>
        <c:when test="${not empty sessionScope.cart}">
            <form action="submitBorrowCart" method="post">
                <table class="table table-bordered table-striped">
                    <thead>
                    <tr>
                        <th>图书编号</th>
                        <th>书名</th>
                        <th>作者</th>
                        <th>借阅时间（天）</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <c:forEach var="book" items="${sessionScope.cart}" varStatus="s">
                        <tr>
                            <td>${book.id}
                            </td>
                            <td>${book.title}</td>
                            <td>${book.author}</td>
                            <td>
                                <div class="mb-3">
                                    <input type="number" class="form-control"
                                           id="day${s.index}"
                                           name="days"
                                           value="1" min="1" step="1" max="365">
                                    <label for="day${s.index}" class="form-label">天</label>
                                </div>
                            </td>
                            <td>
                                <a href="deleteBorrowCart/${book.id}">删除</a>
                            </td>
                        </tr>
                    </c:forEach>
                    </tbody>
                </table>
                <button type="submit" class="btn btn-primary">提交借阅</button>
            </form>
            <form action="${pageContext.request.contextPath}/back" method="post" class="text-center">
                <button class="btn btn-outline-secondary back-btn" type="submit" name="action" value="back">返回首页</button>
            </form>
        </c:when>
        <c:otherwise>
            <p>清单为空。</p>
        </c:otherwise>
    </c:choose>

</div>
<%@include file="/asserts/common/footer.jsp" %>
<script src="${pageContext.request.contextPath}/asserts/js/utils/dynamicBG.js"></script>
</body>
</html>